﻿using System;
using System.Collections.Specialized;

namespace CF.Service
{
    public class Cmds
    {
        public static string ColumnLength = "\r\n\t\t[Column(Name = \"ColumnName\", DbType = \"ColumnLength\")]";
        public static string privateColumn = "\r\n\t\tprivate {1} _{0};{2}";
        public static string publicColumn = "\r\n\t\tpublic ColumnType ColumnName\r\n\t\t{\r\n\t\t\tget { return _ColumnName; }\r\n\t\t\tset { _ColumnName = value; }\r\n\t\t}";

        public static string strQuery = "\r\n\t\t\tpropName = \"ColumnName\";\r\n\t\t\tif (!string.IsNullOrEmpty(ps[propName]))\r\n\t\t\t{\r\n\t\t\t\texp &= TTableName.ColumnName == ColumnFormat;\r\n\t\t\t}";

        public static string strRecordField = "\r\n\t\t\t\t\t\t<ext:RecordField Name=\"{0}\" />";
        public static string strGridField = "\r\n\t\t\t\t\t<ext:{2} Header=\"{1}\" DataIndex=\"{0}\" Width=\"80\" />";
        public static string strEditField = "\r\n\t\t\t\t\t\t\t\t<ext:{2} ID=\"txt{0}\" FieldLabel=\"{1}\" AnchorHorizontal=\"98%\" runat=\"server\" {3}/>";

        public static string strInitInfo = "\r\n\t\t\ttxt{0}.Text = string.Empty;";
        public static string strInitInfo_Checked = "\r\n\t\t\ttxt{0}.Checked = true;";
        public static string strSetInfo = "\r\n\t\t\ttxt{0}.Text = tt.{0};";
        public static string strSetInfo_Checked = "\r\n\t\t\ttxt{0}.Text = tt.{0} == \"1\";";
        public static string strSaveInfo = "\r\n\t\t\ttt.{0} = txt{0}.Text;";
        public static string strSaveInfo_DateTime = "\r\n\t\t\ttt.{0} = DateTime.Now;";
        public static string strSaveInfo_Checked = "\r\n\t\t\ttt.{0} = \"1\";";

        public static string strDesignerField = "\r\n\t\t/// <summary>\r\n\t\t/// txt{0} 控件。\r\n\t\t/// </summary>\r\n\t\t/// <remarks>\r\n\t\t/// 自动生成的字段。\r\n\t\t/// 若要进行修改，请将字段声明从设计器文件移到代码隐藏文件。\r\n\t\t/// </remarks>\r\n\t\tprotected global::Ext.Net.{1} txt{0};";

        public static NameValueCollection sqliteType = new NameValueCollection()
        {
            {"int","integer"},
            {"long","bigint"},
            {"float","float"},
            {"double","money"},
            {"string","nvarchar(20)"},
            {"bool","bit"},
            {"DateTime","datetime"}
        };

        public static NameValueCollection ExtCSSaveInfo = new NameValueCollection()
        {
            {"int","\r\n\t\t\ttt.{0} = int.Parse(txt{0}.Text);"},
            {"long","\r\n\t\t\ttt.{0} = long.Parse(txt{0}.Text);"},
            {"float","\r\n\t\t\ttt.{0} = float.Parse(txt{0}.Text);"},
            {"double","\r\n\t\t\ttt.{0} = double.Parse(txt{0}.Text);"},
            {"string","\r\n\t\t\ttt.{0} = txt{0}.Text;"},
            {"bool","\r\n\t\t\ttt.{0} = txt{0}.Checked;"},
            {"DateTime","\r\n\t\t\ttt.{0} = DateTime.Now;"}
        };
    }
}
